package leetcode_400;

import java.util.List;

/**
 *@author 周杨
 *MiniParser_385 返回一个迷你迭代器
*Given s = "[123,[456,[789]]]",
		
		Return a NestedInteger object containing a nested list with 2 elements:
		
		1. An integer containing value 123.
		2. A nested list containing two elements:
		    i.  An integer containing value 456.
		    ii. A nested list with one element:
		         a. An integer containing value 789.
 *describe:AC 99%
 *2018年7月11日 下午3:20:49
 */
public class MiniParser_385 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}
	public interface NestedInteger{
		
	}
	
	
	/*public interface NestedInteger {
		      // Constructor initializes an empty nested list.
		      public NestedInteger() ;
		 
		      // Constructor initializes a single integer.
		      public NestedInteger(int value);
		
		      // @return true if this NestedInteger holds a single integer, rather than a nested list.
		      public boolean isInteger();
		 
		     // @return the single integer that this NestedInteger holds, if it holds a single integer
		      // Return null if this NestedInteger holds a nested list
		      public Integer getInteger();
		 
		     // Set this NestedInteger to hold a single integer.
		      public void setInteger(int value);
		 
		      // Set this NestedInteger to hold a nested list and adds a nested integer to it.
		      public void add(NestedInteger ni);
		 
		      // @return the nested list that this NestedInteger holds, if it holds a nested list
		     // Return null if this NestedInteger holds a single integer
		      public List<NestedInteger> getList();
		  }*/
	
	 /*int i = 0;
	 public NestedInteger deserialize(String s) {
	        if (i >= s.length()) {
	            return null;
	        }
	        
	        if (s.charAt(i) == '-' || Character.isDigit(s.charAt(i))) {
	            int num = 0;
	            boolean isPos = true;
	            if (s.charAt(i) == '-') {
	                isPos = false;
	                ++i;
	            }
	            while (i < s.length() && Character.isDigit(s.charAt(i))) {
	                num = num * 10 + s.charAt(i) - '0';
	                ++i;
	            }
	            return new NestedInteger(isPos ? num : -num);
	        }
	        NestedInteger res = new NestedInteger();
	        ++i;
	        while (i < s.length() && s.charAt(i) != ']') {
	            NestedInteger child = deserialize(s);
	            res.add(child);
	            if (i < s.length() && s.charAt(i) == ',') {
	                ++i;
	            }
	        }
	        ++i;
	        return res;
	    }*/
}
